// Author: Bjorn Schobben

#ifndef MAP_H
#define MAP_H

#include <list>
#include "Land.h"

class Map
{
public:

	// Constructors
	Map();
	Map(const Map& rhs);

	// Destructor
	virtual ~Map();

	// Clear all lands from map
	void Clear();

	// Copy contents from another map
	void Copy(const Map& rhs);

	// Update neighbours for all lands in this map
	void UpdateNeighbours();

	// Test if land is filled in with unique colors as in the 4-color problem
	bool IsCompleted() const;

	// Set color of a land's province
	bool SetColor(const std::string& landName, const std::string& provinceName, Color color);

	// Get the amount of unique colors used in the map
	unsigned int GetUniqueColorCount() const;

	// Load map from file
	virtual bool LoadFromFile(const std::string& filename);

	// Get pointer to land based on land name
	Land* GetLand(const std::string& landName);
	const Land* GetLand(const std::string& landName) const;

	Map& operator=(const Map& rhs);

	// Operations on land list
	std::list<Land*>& GetLands();
	virtual Land* InsertNewLand(const std::string& name);
	virtual Land* InsertNewLand(const Land& land);
protected:
	virtual Land* InsertLand(Land* land);
	

	std::list<Land*> lands;
private:
	bool ProcessCoordinates(Province* province, const std::string& coordinates) const;
	bool ProcessLine(Land **land, const std::string& line);
};

#endif //MAP_H